/**pause*/

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<unistd.h>
#include<signal.h>

static void sig_handler(int sig)
{
	printf("received sig:%d\n",sig);
	puts("alarm timeout");
}

int main(int argc,char *argv[])
{
	struct sigaction sig={0};
	int second;
	if(2>argc)
		exit(-1);
	sig.sa_handler=sig_handler;
	sig.sa_flags=0;
	if(-1==sigaction(SIGALRM,&sig,NULL)){
		perror("sigaction error");
		exit(-1);
	}

	second=atoi(argv[1]);
	printf("time:%d seconds \n",second);
	alarm(second);
	pause();
	puts("sleep end");


	exit(0);
}
